package org.ifi.xechecs.board;

public class Piece {
    public static byte WHITE = 1;
    public static byte BLACK = -1;

    public static final byte NONE = 0;
    public static final byte WK = 1;
    public static final byte WQ = 2;
    public static final byte WB = 3;
    public static final byte WN = 4;
    public static final byte WR = 5;
    public static final byte WP = 6;
    public static final byte BK = 7;
    public static final byte BQ = 8;
    public static final byte BB = 9;
    public static final byte BN = 10;
    public static final byte BR = 11;
    public static final byte BP = 12;

    public static final byte KING = 1;
    public static final byte QUEEN = 2;
    public static final byte BISHOP = 3;
    public static final byte KNIGHT = 4;
    public static final byte ROOK = 5;
    public static final byte PAWN = 6;
    
    private static char[] chars = {'.', 'K', 'Q', 'B', 'N', 'R', 'P', 'k', 'q', 'b', 'n', 'r', 'p'};    
    
    public static char toChar(byte piece) {
        return chars[piece];
    }
    
    public static byte getColor(byte piece) {
    	
		if (piece >= 1 && piece <= 6){
			return WHITE;
		} else if(piece >= 7 && piece <= 12){
			return BLACK;
		}
		return NONE;
	}
    
    public static byte getType(byte piece){
    	if(piece > 6){
    		return (byte)(piece - 6);
    	}
    	return piece;
    }
}
